<?php
/**
 * CompleXml Framework
 *
 * @category   CompleXml
 * @package    CompleXml_Dataset
 * @copyright  Copyright (c) 2008 Andrey Kucherenko
 * @license    New BSD License
 * @version    $Id: Request.php 57 2009-10-25 19:38:43Z kucherenko.andrey $
 */

#require_once 'CompleXml/Dataset.php';

/**
 * Класс, работающий с множеством данных запроса пользователя
 */
class CompleXml_Dataset_Request extends CompleXml_Dataset
{
    /**
     *
     * @var CompleXml_Dataset
     */
    public $Post;
    /**
     *
     * @var CompleXml_Dataset
     */
    public $Get;
    /**
     *
     * @var CompleXml_Dataset
     */
    public $Uri;

    public function __construct ()
    {
        parent::__construct($_REQUEST);
        $this->Post = new CompleXml_Dataset($_POST);
        $this->Get = new CompleXml_Dataset($_GET);
        $url_array =  (array) explode('?', $_SERVER['REQUEST_URI']);
        $source = explode('/', $url_array[0]);
        foreach ($source as $key=>$value) {
            if (empty($value)){
                unset($source[$key]);
            }
        }
        $this->Uri = new CompleXml_Dataset($source);
    }

    public function isPost()
    {
        return $_SERVER['REQUEST_METHOD']=='POST';
    }

    public function isGet()
    {
        return $_SERVER['REQUEST_METHOD']=='GET';
    }
}
